package com.example.backspring.controller;

import com.example.backspring.Service.impl.BookServiceImpl;
import com.example.backspring.config.Message;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/search")
@Tag(name = "图书搜索", description = "图书搜索接口")
public class Search {

    @Resource
    private BookServiceImpl bookService;

    @PostMapping("/book")
    @Operation(summary = "添加图书", description = "根据图书名称、作者和价格添加新图书")
    public Message getBook(@RequestParam String name, @RequestParam String author, @RequestParam double price) {
        Message res = bookService.addBook(name, author, price);
        return res;
    }
}
